import fetch from 'common/src/utils/fetch';
import baseUrl from './env';
function searchInnovativeDic(data) {
    return fetch({
        url: `${baseUrl}/sysDictionary/getSubDicList`,
        method: 'get',
        params: data
    });
}
// 获取学院权限列表数据
function getfacultyPermissionData(data) {
    return fetch({
        url: `${baseUrl}/facultyPermission/getList`,
        method: 'post',
        data
    });
}
// 删除学院权限
function deletefacultyPermissionById(code) {
    return fetch({
        url: `${baseUrl}/facultyPermission/delete`,
        method: 'post',
        data: code
    });
}
// 新增学院权限
function addfacultyPermission(data) {
    return fetch({
        url: `${baseUrl}/facultyPermission/addOrEdit`,
        method: 'post',
        data
    });
}
// 新增学院权限
function findSelectList(data) {
    return fetch({
        url: '/api/studentservice/teacherInfo/findSelectList',
        method: 'post',
        data
    });
}
// 获取所有学院
function getAllFaculty() {
    const data = {
        'currentState': 1,
        'isFaculty': 1,
        'isUnderStudent': 1
    };
    return fetch({
        url: `/api/userservice/dept/list`,
        method: 'post',
        data
    });
}
// // 获取登录人是学院还是学校角色
// function getLoginRoleType() {
//     return fetch({
//         url: `${baseUrl}/userGroup/achievementRoleInfo`,
//         method: 'get'
//     });
// }

// 获取登录人是学院还是学校角色
function getLoginRoleType() {
    let flag = false
    if (localStorage.getItem('sessiondata')) {
        // 获取当前用户auths权限
        if (JSON.parse(localStorage.getItem('sessiondata')).auths) {
            this.auths = JSON.parse(localStorage.getItem('sessiondata')).auths
            if (this.auths) {
                this.auths.forEach(val => {
                    if (val.authCode === 'innovative-tempSet-ifAdmin') {
                        flag = true
                    }
                })
            }
        }
    }
    const testPro = new Promise((resolve, reject) => {
        if (flag) {
            resolve({
                code: 200,
                data: {
                    schoolAdmin: true
                },
                msg: ''
            })
        } else {
            resolve({
                code: 200,
                data: {
                    schoolAdmin: false
                },
                msg: ''
            })
        }
        
    }).catch(e => {
        // reject(e);
    })
    return testPro
}

// 获取登录人角色
function getLoginRole() {
    return fetch({
        url: `${baseUrl}/userGroup/abilityDevelopAccreditation`,
        method: 'get'
    });
}
// 获取期刊类型字典数据
function getSearchTypeList(params) {
    return fetch({
        url: `${baseUrl}/sysDictionary/getSearchTypeList`,
        method: 'get',
        params: params
    });
}
// 课程负责人（模糊查询接口）
function findTeacherList(data) {
    return fetch({
        url: `${baseUrl}/facultyCheck/findTeacherList`,
        method: 'post',
        data
    });
}
// 课程负责人（模糊查询接口）
function getTeacherInfoByCodeOrName(data) {
    return fetch({
        url: `${baseUrl}/facultyPermission/getTeacherInfoByCodeOrName`,
        method: 'post',
        data
    });
}
// 根据条件，分页查询课程
export function getCourseList(data) {
    return fetch({
        url: `${baseUrl}/schoolAffirmTime/queryCourseListByVo`,
        method: 'POST',
        data
    });
}
// 成绩同步
function synchronization(data) {
    return fetch({
        url: `${baseUrl}/practice/synchronization`,
        method: 'post',
        data
    });
  }
// 获取登录人专业
function queryProfession() {
    return fetch({
        url: `${baseUrl}/sysDictionary/queryProfession`,
        method: 'get'
    });
}

// 获取登录人专业
function getFacultyList() {
    return fetch({
        url: `${baseUrl}/facultyCheck/getFacultyList`,
        method: 'get'
    });
}

export default {
    'searchInnovativeDic': searchInnovativeDic,
    'getfacultyPermissionData': getfacultyPermissionData,
    'deletefacultyPermissionById': deletefacultyPermissionById,
    'addfacultyPermission': addfacultyPermission,
    'findSelectList': findSelectList,
    'getAllFaculty': getAllFaculty,
    'getLoginRoleType': getLoginRoleType,
    'getLoginRole': getLoginRole,
    'getSearchTypeList': getSearchTypeList,
    getTeacherInfoByCodeOrName,
    findTeacherList,
    getCourseList,
    'synchronization':synchronization,
    'queryProfession': queryProfession,
    'getFacultyList': getFacultyList
};

